package com.smooth.site.sx.mag.biz.compcollege.comp.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.smooth.dao.gen.BizCompCollegeMapper;
import com.smooth.dao.gen.bean.BizCompCollege;
import com.smooth.dao.gen.bean.BizCompCollegeExample;
import com.smooth.site.sx.mag.biz.compcollege.comp.enums.IsCheckedEnums;

@Component
public class PcCollegeCompService {
	@Autowired
	BizCompCollegeMapper bizCompCollegeMapper;
	
	public List<BizCompCollege> querCompListByCollegeD(String collegeId){
		BizCompCollegeExample bizCompCollegeExample = new BizCompCollegeExample();
		
		BizCompCollegeExample.Criteria criteria = bizCompCollegeExample.createCriteria();
		criteria.andCollegeIdEqualTo(collegeId);
		criteria.andIsCheckedEqualTo(IsCheckedEnums.checked.value);
		List<BizCompCollege> blist = bizCompCollegeMapper.selectByExample(bizCompCollegeExample);
		
		return blist;
	}
	
	
	public List<String> querCompListByCollege(String collegeId){
		BizCompCollegeExample bizCompCollegeExample = new BizCompCollegeExample();
		
		BizCompCollegeExample.Criteria criteria = bizCompCollegeExample.createCriteria();
		criteria.andCollegeIdEqualTo(collegeId);
		criteria.andIsCheckedEqualTo(IsCheckedEnums.checked.value);
		List<BizCompCollege> blist = bizCompCollegeMapper.selectByExample(bizCompCollegeExample);
		
		List<String> compList = new ArrayList<String>();
		for(BizCompCollege bizCompCollege : blist) {
			if(!compList.contains(bizCompCollege.getCompanyId())) {
				compList.add(bizCompCollege.getCompanyId());
			}
		}
		
		return compList;
	}
	
	
	public List<String> querCollegeByComp(String compId){
		BizCompCollegeExample bizCompCollegeExample = new BizCompCollegeExample();
		
		BizCompCollegeExample.Criteria criteria = bizCompCollegeExample.createCriteria();
		criteria.andCompanyIdEqualTo(compId);
		criteria.andIsCheckedEqualTo(IsCheckedEnums.checked.value);
		List<BizCompCollege> blist = bizCompCollegeMapper.selectByExample(bizCompCollegeExample);
		
		List<String> compList = new ArrayList<String>();
		for(BizCompCollege bizCompCollege : blist) {
			if(!compList.contains(bizCompCollege.getCollegeId())) {
				compList.add(bizCompCollege.getCollegeId());
			}
		}
		
		return compList;
	}
}
